package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SysUnit;
import com.ruoyi.system.service.SysUnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Api(tags = "单位管理")
@RestController
@RequestMapping("/api")

public class SysUnitController extends BaseController {
    @Autowired
    SysUnitService service;
    @ApiOperation("单位列表")
    @PostMapping("/unit")
    public TableDataInfo queryAll(@RequestBody SysUnit unit){
        startPage();
        List list=service.queryAll(unit);
        return getDataTable(list);
    }
    @PostMapping("/unitAdd")
    @ApiOperation("插入单位")
    public AjaxResult insert(@RequestBody SysUnit unit){
        return service.insert(unit)>0?success("插入成功"):error("插入失败");
    }
}
